<%-- 
    Document   : latestdecks
    Created on : Mar 15, 2012, 3:11:15 PM
    Author     : User
--%>

<%@page import="ua.org.mtgatherer.entities.DeckCard"%>
<%@page import="ua.org.mtgatherer.entities.TcgPlayerDeck"%>
<%@page import="ua.org.mtgatherer.persistence.PMF"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="ua.org.mtgatherer.deckloaders.TcgPlayerDeckLoader"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Latest decks</title>
   </head>
   <body>
      <%  List<String> deckIds = TcgPlayerDeckLoader.getFirstPlaceDecksNumbers("3/1/2012", "3/14/2012");


         PersistenceManager pm = PMF.get().getPersistenceManager();

         try {
            for (String deckId : deckIds) {
               TcgPlayerDeck deck = TcgPlayerDeckLoader.getDeckByNumber(deckId);

               List<DeckCard> deckCardList = deck.getDeck().getDeckList();

               pm.makePersistent(deck);

      %>
      <h1><%= deck.getOwner()%> - <%= deck.getTitle()%></h1>
      <%

         for (DeckCard deckCard : deckCardList) {
      %>
      <b><%= deckCard.toString()%></b><br>
      <%
               }
            }
         } finally {
            pm.close();
         }

        
        %>

   </body>
</html>
